//
//  DBHelper.h
//  sweetbox
//
//  Created by apollo on 15/9/15.
//  Copyright (c) 2015年 proj-m. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <FMDB/FMDB.h>

@interface DBHelper : NSObject

@property (nonatomic, readonly) FMDatabase *dictDB;
@property (nonatomic, readonly) FMDatabase *presDB;


+ (DBHelper *)sharedDBHelper;

- (DBHelper *) initWithNil;

- (BOOL) createDictDB:(NSString *)platform openID:(NSString *)openID;
- (BOOL) openDictDB:(NSString *)platform openID:(NSString *)openID;
- (void) closeDictDB;

- (BOOL) insertWord:(NSString *)word translate:(NSString *)translate;
- (BOOL) updateWord:(NSString *)word translate:(NSString *)translate;
- (int) countWrods;
- (NSArray *) wordAt:(int) index;
- (NSArray *) wordAtKey:(NSString *)key;
- (BOOL) deleteWord:(NSString *) word;

- (BOOL) createPresDB:(NSString *)platform openID:(NSString *)openID;
- (BOOL) openPresDB:(NSString *)platform openID:(NSString *)openID;
- (void) closePresDB;

- (BOOL) insertBook:(NSString *)name brief:(NSString *)brief;
- (BOOL) updateBook:(NSString *)name brief:(NSString *)brief;
- (int) countBooks;
- (NSArray *) bookAt:(int) index;
- (NSArray *) bookAtName:(NSString *)name;
- (BOOL) deleteBook:(NSString *) name;

- (BOOL) insertScript:(NSString *)bookName title:(NSString *)title script:(NSString *)script;
- (BOOL) updateScript:(NSString *)bookName title:(NSString *)title script:(NSString *)script;
- (int) countScript:(NSString *)bookName;
- (NSArray *) scriptAt:(NSString *)bookName index:(int) index;
- (NSArray *) scriptAtTitle:(NSString *)bookName title:(NSString *)title;
- (BOOL) deleteScript:(NSString *)bookName title:(NSString *) title;

@end
